<a href='https://github.com/angular/angular.js/edit/v1.5.x/src/ng/directive/attrs.js?message=docs(ngReadonly)%3A%20describe%20your%20change...#L225' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>



<a href='https://github.com/angular/angular.js/tree/v1.5.8/src/ng/directive/attrs.js#L225' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">ngReadonly</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
    <li>
      - directive in module <a href="api/ng">ng</a>
    </li>
  </ol>
</header>



<div class="api-profile-description">
  <p>Sets the <code>readonly</code> attribute on the element, if the expression inside <code>ngReadonly</code> is truthy.
Note that <code>readonly</code> applies only to <code>input</code> elements with specific types. <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-readonly">See the input docs on
MDN</a> for more information.</p>
<p>A special directive is necessary because we cannot use interpolation inside the <code>readonly</code>
attribute. See the <a href="guide/interpolation">interpolation guide</a> for more info.</p>

</div>






<div>
  

  
  <h2>Directive Info</h2>
  <ul>
    
    <li>This directive executes at priority level 100.</li>
    
  </ul>

  
  <h2 id="usage">Usage</h2>
  <div class="usage">
  
    <ul>
    <li>as attribute:
        <pre><code>&lt;INPUT&#10;  ng-readonly=&quot;expression&quot;&gt;&#10;...&#10;&lt;/INPUT&gt;</code></pre>
      </li>
    
  </div>
  
<section class="api-section">
  <h3>Arguments</h3>

<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        ngReadonly
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-expression">expression</a>
      </td>
      <td>
        <p>If the <a href="guide/expression">expression</a> is truthy,
    then special attribute &quot;readonly&quot; will be set on the element</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

</section>
  


  
  <h2 id="example">Example</h2><p>

<div>
  <plnkr-opener example-path="examples/example-example57"></plnkr-opener>

  <div class="runnable-example"
      path="examples/example-example57">

  
    <div class="runnable-example-file" 
      name="index.html"
      language="html"
      type="html">
      <pre><code>&lt;label&gt;Check me to make text readonly: &lt;input type=&quot;checkbox&quot; ng-model=&quot;checked&quot;&gt;&lt;/label&gt;&lt;br/&gt;&#10;&lt;input type=&quot;text&quot; ng-readonly=&quot;checked&quot; value=&quot;I&#39;m Angular&quot; aria-label=&quot;Readonly field&quot; /&gt;</code></pre>
    </div>
  
    <div class="runnable-example-file" 
      name="protractor.js"
      type="protractor"
      language="js">
      <pre><code>it(&#39;should toggle readonly attr&#39;, function() {&#10;  expect(element(by.css(&#39;[type=&quot;text&quot;]&#39;)).getAttribute(&#39;readonly&#39;)).toBeFalsy();&#10;  element(by.model(&#39;checked&#39;)).click();&#10;  expect(element(by.css(&#39;[type=&quot;text&quot;]&#39;)).getAttribute(&#39;readonly&#39;)).toBeTruthy();&#10;});</code></pre>
    </div>
  

    <iframe class="runnable-example-frame" src="examples/example-example57/index.html" name="example-example57"></iframe>
  </div>
</div>


</p>

</div>


